package com.bytedance.retrofit2.client;

import com.bytedance.retrofit2.mime.TypedOutput;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public final class Request {
    public final String method;
    public final String url;
    public final List<Header> headers;
    public final TypedOutput body;
    public final boolean isStreaming;
    public final int f;
    public Object g;

    public Request(String method, String url, List<Header> headers, TypedOutput body, boolean isStreaming, int arg8, Object arg9) {
        if (method == null) {
            throw new NullPointerException("Method must not be null.");
        }

        if (url == null) {
            throw new NullPointerException("URL must not be null.");
        }

        this.method = method;
        this.url = url;
        this.headers = headers == null ? Collections.emptyList() : Collections.unmodifiableList(new ArrayList(((Collection) headers)));
        this.body = body;
        this.isStreaming = isStreaming;
        this.f = arg8;
        this.g = arg9;
    }

    public final Header getHeader(String name) {
        if (this.headers == null) {
            return null;
        } else {
            Iterator<Header> iterator = this.headers.iterator();
            while (iterator.hasNext()) {
                Header header = iterator.next();
                if (name.equalsIgnoreCase(header.name)) {
                    return header;
                }
            }
            return null;
        }
    }
}

